home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/ports.h>
- #include <exec/io.h>
- #include <fakesr.h>
- #include <proto/exec.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- struct IOStdReq *FsrCtl=NULL;
- struct MsgPort *CtlPort=NULL;
- struct FSRUnit *Unit=NULL;
- int UnitAdded=FALSE;
- int OpenCnt=0;
- int CloseUnitFlag=FALSE;
- int CloseUnitSignal=-1;
- struct Task *TestTask;
-
- void Quit(int retcode)
- {
- if (FsrCtl) {
- if (FsrCtl->io_Device) CloseDevice(FsrCtl);
- DeleteStdIO(FsrCtl);
- }
- if (CtlPort) DeletePort(CtlPort);
- exit(retcode);
- }
-
- ULONG OpenTest(void *IORequest)
- {
- OpenCnt++;
- CloseUnitFlag=TRUE;
- Signal(TestTask,1<<CloseUnitSignal);
- }
-
- ULONG CloseTest(void *IORequest)
- {
-
- }
-
- ULONG Test_BeginIO(void *IORequest)
- {
-
- }
-
- ULONG Test_AbortIO(void *IORequest)
- {
- return 0; /* we don't support this */
- }
-
- void main(void)
- {
-
- CtlPort=CreatePort(NULL,0);
- if (!CtlPort) Quit(21);
- FsrCtl=CreateStdIO(CtlPort);
- if (!FsrCtl) Quit(22);
-
- if (OpenDevice("fakesr.device",FSR_CTLUNIT,FsrCtl,0)) {
- FsrCtl->io_Device=NULL;
- Quit(23);
- }
- Unit=calloc(sizeof(struct FSRUnit),1);
- if (!Unit) Quit(24);
- Unit->fsru_Num=FSR_UNITNONE;
- Unit->fsru_Open=OpenTest;
- Unit->fsru_Close=CloseTest;
- Unit->fsru_BeginIO=Test_BeginIO;
- Unit->fsru_AbortIO=Test_AbortIO;
-
- FsrCtl->io_Command=FSRCMD_ADDUNIT;
- FsrCtl->io_Data=(APTR)Unit;
- DoIO(FsrCtl);
- UnitAdded=TRUE;
- FsrCtl->io_Command=FSRCMD_REMUNIT;
- FsrCtl->io_Data=(APTR)Unit;
- DoIO(FsrCtl);
- UnitAdded=FALSE;
- CloseDevice(FsrCtl);
- }
-